import router from './router'

import {
  Message
} from 'element-ui'

import {
  getToken
} from '@/utils/auth'
import {
  basePath,
  basePath2
} from '@/common'

router.beforeEach(async (to, from, next) => {

  const hasToken = getToken()
  if (hasToken) {
    if (to.path === '/login') {
      next({
        path: '/index'
      })

    } else {
      // const url = window.location.href
      // const index = url.indexOf('qx=')
      // if (index !== 0) {

      //   next()
      // } else {
      //   let url = "";
      //   if (process.env.NODE_ENV == "development") {
      //     url = basePath;
      //   } else {
      //     url = basePath2;
      //   }
      //   window.location.href = url + "/#/"
      // }
      next()

    }
  } else {
    next()
  }
})


